/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */

package cn.com.ksplatform.modules.system.auth.orgmanager.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import cn.com.ksplatform.base.BaseModel;

/**
 * @ClassName:PlatOrg <br/>
 * @deprecated:TODO. <br/>
 * @Date: 2015年5月21日 下午4:35:00 <br/>
 * 
 * @author Mr.Luoxing
 * @version 1.0
 */

@Entity
@Table(name = "t_sys_org")
@DynamicUpdate(true)
public class PlatOrg extends BaseModel {
	@Id
	@GenericGenerator(name = "systemUUID", strategy = "uuid")
	@GeneratedValue(generator = "systemUUID")
	@Column(name = "orgId")
	private String orgId;
	@Column(unique=true,nullable=false)
	private String orgCode;
	private String orgName;
	private String enabled;

	@ManyToOne(cascade = { CascadeType.MERGE })
	@JoinColumn(name = "parent_id")
	@JsonIgnore
	private PlatOrg parent_org;

	@OneToMany(mappedBy = "parent_org",cascade={ CascadeType.PERSIST},fetch=FetchType.LAZY)
	@JsonIgnore
	private Set<PlatOrg> children = new HashSet<PlatOrg>(0);

	@OneToMany(mappedBy = "org")
	@JsonIgnore
	private Set<PlatStation> stations = new HashSet<PlatStation>(0);

	
	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getEnabled() {
		return enabled;
	}

	public void setEnabled(String enabled) {
		this.enabled = enabled;
	}

	public Set<PlatStation> getStations() {
		return stations;
	}

	public void setStations(Set<PlatStation> stations) {
		this.stations = stations;
	}

	public PlatOrg getParent_org() {
		return parent_org;
	}

	public void setParent_org(PlatOrg parent_org) {
		this.parent_org = parent_org;
	}

	public Set<PlatOrg> getChildren() {
		return children;
	}

	public void setChildren(Set<PlatOrg> children) {
		this.children = children;
	}

}
